﻿namespace LeetCodeProject._0001_1000._001_100._011;

public class Solution
{
    public int MaxArea(int[] height)
    {
        int left = 0;
        int right = height.Length - 1;
        int res = 0;
        while (left < right)
        {
            int area = Math.Min(height[left], height[right]) * (right - left);
            res = Math.Max(res, area);
            if (height[left] <= height[right])
            {
                ++left;
            }
            else
            {
                --right;
            }
        }

        return res;
    }
}